package com.lmc.adapter;


import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.lmc.R;
import com.lmc.entity.Members;
import com.lmc.util.GlideUtil;
import com.qxzn.app.bean.FamilyMemberBean;
import com.qxzn.app.page.util.GlideImageLoader;

import java.util.List;

public class MemberAdapter extends RecyclerView.Adapter<MemberAdapter.ViewHolder> {
    List<FamilyMemberBean.MemberBean> dataList;
    Context context;

    public MemberAdapter(List<FamilyMemberBean.MemberBean> itemList, Context context) {
        dataList = itemList;
        this.context = context;
    }

    @NonNull
    @Override
    public MemberAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new ViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.lmc_health_member_layout, parent, false));
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        FamilyMemberBean.MemberBean bean = dataList.get(position);
        holder.name.setText(bean.getNiname());
//        bean.setHeadportrait("https://hznt-mall.oss-cn-shenzhen.aliyuncs.com/home/avatar/avatar_110499_1556671973558.jpg");
        GlideUtil.setImg(context, holder.icon, bean.getHeadportrait());
    }

    @Override
    public int getItemCount() {
        return dataList.size();
    }

    static class ViewHolder extends RecyclerView.ViewHolder {
        ImageView icon;
        TextView name;

        public ViewHolder(View itemView) {
            super(itemView);
            icon = itemView.findViewById(R.id.iv_member_icon);
            name = itemView.findViewById(R.id.tv_member_name);
        }
    }

}
